﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Medicae_Toolkit
{
    public partial class PMedicae : Form
    {
        public Medicae PForm;
        public PMedicae(Medicae m)
        {
            InitializeComponent();
            PForm = m;
            UpdateList();
        }

        private void PMedicae_Load(object sender, EventArgs e)
        {

        }

        public void UpdateList()
        {
            listBox1.Items.Clear();
            listBox1.Items.AddRange(PForm.Churigeons.ToArray());
            PForm.UpdateList();
        }

        private void editButton_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem == null)
                return;

            (new MedicaeEditor(this, (Churigeon)listBox1.SelectedItem, false)).Show();
             
        }

        private void newButton_Click(object sender, EventArgs e)
        {
            (new MedicaeEditor(this, new Churigeon(), true)).Show();
        }

        private void Party_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar.ToString() == Keys.Enter.ToString())
            {
                editButton_Click(sender, e);
            }
            if (e.KeyChar.ToString() == Keys.Escape.ToString())
            {
                Close();
            }
        }

    }
}
